<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>
<#import "/macro/FormItem.ftl" as Form>

<@header title="用户编辑">
    <link href="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet">
</@header>

<@body>
<h2 class="module-title">用户编辑</h2>

<div class="alert alert-primary" role="alert">
    <button class="btn btn-info" onclick="javascript: history.back(-1);return false;" >返回</button>
</div>

<form class="form-horizontal" id="imUserForm" action="${ctx}/imUser/save" method="post">
    <input type="hidden" name="id" value="${imUser.id}"/>
    <@Form.FormItem name="code" label="登录码">
        <input type="text" class="form-control" name="code" id="code" aria-describedby="登录码" value="${imUser.code}">
    </@Form.FormItem>
    <@Form.FormItem name="password" label="登录密码">
        <input type="text" class="form-control" name="password" id="password" aria-describedby="登录密码" value="${imUser.password}">
    </@Form.FormItem>
    <@Form.FormItem name="tenantId" label="租户">
        <select class="form-control" name="tenantId" id="tenantId">
            <#list tenants as tenant>
                <option value="${tenant.id}" <#if tenant.id == imUser.tenantId>selected</#if>>${tenant.description}</option>
            </#list>
        </select>
    </@Form.FormItem>
    <@Form.FormItem name="departmentId" label="部门id">
        <input type="text" class="form-control" name="departmentId" id="departmentId" aria-describedby="部门id" value="${imUser.departmentId}">
    </@Form.FormItem>
    <@Form.FormItem name="mobile" label="手机号">
        <input type="text" class="form-control" name="mobile" id="mobile" aria-describedby="手机号" value="${imUser.mobile}">
    </@Form.FormItem>
    <@Form.FormItem name="headImg" label="头像">
        <input type="text" class="form-control" name="headImg" id="headImg" aria-describedby="头像" value="${imUser.headImg}">
    </@Form.FormItem>
    <@Form.FormItem name="motto" label="座右铭">
        <input type="text" class="form-control" name="motto" id="motto" aria-describedby="座右铭" value="${imUser.motto}">
    </@Form.FormItem>
    <@Form.FormItem name="sex" label="性别">
        <select class="form-control" name="sex" id="sex">
            <#list sexEnums as sex>
                <option value="${sex}" <#if sex == imUser.sex>selected</#if>>${sex.desc}</option>
            </#list>
        </select>
    </@Form.FormItem>
    <@Form.FormItem name="enable" label="是否可用">
        <select class="form-control" name="enable" id="enable">
            <#list statusValues as status>
                <option value="${status}" <#if status == imUser.status>selected</#if>>${status.desc}</option>
            </#list>
        </select>
    </@Form.FormItem>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary">提交</button>
        </div>
    </div>
</form>
</@body>

<@footer>
    <script src="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.full.min.js"></script>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $('#loginTime').datetimepicker({
                format:'Y-m-d H:i:s',
                lang:'zh'});
            $('#createTime').datetimepicker({
                format:'Y-m-d H:i:s',
                lang:'zh'});
            $('#updateTime').datetimepicker({
                format:'Y-m-d H:i:s',
                lang:'zh'});
        });

        $().ready(function() {
            $("#imUserForm").validate({
                rules: {
                    id: {
                        required: true,
                        digits: true
                    },
                    code: "required" ,
                    password: "required" ,
                   tenantId: "required" ,
                    departmentId: {
                        required: true,
                        digits: true
                    },
                   mobile: {
                      maxlength: 15
                   },
                   headImg: {
                      maxlength: 256
                   },
                   motto: {
                      maxlength: 516
                   },
                   sex: "required" ,
                    enable: {
                        required: true,
                        digits: true
                    },
                   loginTime: {
                      maxlength: 26
                   },
                    createTime: {
                        required: true,
                        date: true
                    },
                    updateTime: {
                        required: true,
                        date: true
                    }
                }
            });
        });
    </script>
</@footer>